package com.ysx.student.zhangqingrong.com.ysx.day4;

import java.util.Scanner;

/**
 * @author 张青荣
 */
public class Test1 {


    public static void main(String[] args) {
        getCounter();

    }

    private static void getCounter() {
        int sum = 0;
        while (true) {
            // 键盘录入：
            Scanner scanner = new Scanner(System.in);
            int a = getA(scanner, "请输入第一个数：");

            int b = getA(scanner, "请输入第二个数：");


            String s = getS(scanner);

            // 将输入字符与常见符号对比，然后计算；
            if ("+".equals(s)) {
                sum = getSum(a + b);
            } else if ("-".equals(s)) {
                sum = getSum(a - b);
            } else if ("*".equals(s)) {
                sum = getSum(a * b);
            } else if ("/".equals(s)) {
                sum = getSum(a / b);
            } else if ("%".equals(s)) {
                sum = getSum(a % b);
            } else if ("exit".equals(s)) {
                break;
            } else {
                System.out.println("请重新输入!");
                continue;
            }


            System.out.println(sum);


        }
    }

    private static String getS(Scanner scanner) {
        System.out.println("请输入字符：");
        String s1 = scanner.next();
        return s1;
    }

    private static int getA(Scanner scanner, String s) {
        System.out.println(s);
        return scanner.nextInt();
    }

    private static int getSum(int i) {
        int sum;
        sum = i;
        return sum;
    }


}
